//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System.ComponentModel;
using System.Drawing.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using EntLibContrib.Common.Configuration.Design;

namespace EntLibContrib.Query.Configuration.Design
{
	/// <summary>
	/// Represents a <see cref="ServiceQueryData"/> configuration element.
	/// This class is abstract.
	/// </summary>
	public abstract class ServiceQueryNode : QueryNode
	{
		#region Fields
		private TypeMethodName typeMethodName;
		private string address;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the name of the custom service command to use for this query.
		/// </summary>
		/// <value>The name of the custom service command to use for this query.</value>
		[Editor(typeof(ReferenceEditor), typeof(UITypeEditor))]
		[ReferenceType(typeof(ServiceCommandNode))]
		[QueryCategory("CategoryCustom")]
		[QueryDescription("ServiceQueryCommandNameDescription")]
		public ServiceCommandNode ServiceCommandName
		{
			get { return (ServiceCommandNode)CustomCommand; }
			set
			{
				CustomCommand = LinkNodeHelper.CreateReference<ServiceCommandNode>(ServiceCommandName,
																																					value,
																																					OnCustomCommandNodeRemoved,
																																					OnCustomCommandNodeRenamed);
				CustomCommandName = (null == CustomCommand) ? string.Empty : CustomCommand.Name;
			}
		}

		/// <summary>
		/// Gets or sets the name of the service.
		/// </summary>
		/// <value>The service name for this node.</value>
		[QueryCategory("CategoryProvider")]
		[QueryDescription("ServiceQueryTypeMethodNameDescription")]
		public virtual TypeMethodName TypeMethodName
		{
			get { return typeMethodName; }
			set
			{
				if (value != null)
					typeMethodName = value;
			}
		}

		/// <summary>
		/// Gets or sets the address of the service.
		/// </summary>
		/// <value>The service address for this node.</value>
		[QueryCategory("CategoryProvider")]
		[QueryDescription("ServiceQueryAddressDescription")]
		public string Address
		{
			get { return address; }
			set
			{
				if (value != null)
					address = value;
			}
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initialize a new instance of the <see cref="ServiceQueryNode"/> class.
		/// </summary>
		protected ServiceQueryNode ()
		{
		}
		#endregion
	}
}